<meta http-equiv="cache-control" content="no-cache">
<pre>
<?

	mysql_connect("localhost", "canss", "1022") or die("Could not connect: ".mysql_error());

	if( $_GET[dbs] )
	{
		mysql_query( "SET NAMES 'utf8'" );
	mysql_query(" SET SQL_MODE=\"NO_AUTO_VALUE_ON_ZERO\"; ");

	mysql_query(" DROP DATABASE IF EXISTS `contentsmetadata_db`; ");
	mysql_query(" CREATE DATABASE `contentsmetadata_db` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;");
	mysql_query(" USE `contentsmetadata_db`;");
	mysql_query(" DROP TABLE IF EXISTS `tblCID`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `tblCID` (
  `cid` varchar(255) collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (`cid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ");

	mysql_query(" DROP TABLE IF EXISTS `tblChannel`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `tblChannel` (
  `index_2` int(10) unsigned NOT NULL auto_increment,
  `tblPID_pid` varchar(80) collate utf8_unicode_ci NOT NULL,
  `channelname` varchar(255) collate utf8_unicode_ci NOT NULL,
  `outbound_ruleid` varchar(255) collate utf8_unicode_ci default NULL,
  PRIMARY KEY  (`index_2`,`tblPID_pid`),
  KEY `tblChannel_FKIndex1` (`tblPID_pid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; ");

	mysql_query(" DROP TABLE IF EXISTS `tblContent`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `tblContent` (
  `tblCID_cid` varchar(255) collate utf8_unicode_ci NOT NULL,
  `dc_creator` varchar(256) collate utf8_unicode_ci default NULL,
  `dc_date` date default NULL,
  `dc_description` varchar(1024) collate utf8_unicode_ci default NULL,
  `dc_format` varchar(40) collate utf8_unicode_ci default NULL,
  `dc_identifier` varchar(512) collate utf8_unicode_ci default NULL,
  `dc_language` varchar(10) collate utf8_unicode_ci default NULL,
  `dc_publisher` varchar(80) collate utf8_unicode_ci default NULL,
  `dc_rights` varchar(1024) collate utf8_unicode_ci default NULL,
  `dc_sourcetype` varchar(10) collate utf8_unicode_ci default NULL,
  `dc_source` varchar(512) collate utf8_unicode_ci default NULL,
  `dc_subject` varchar(512) collate utf8_unicode_ci default NULL,
  `dc_title` varchar(512) collate utf8_unicode_ci default NULL,
  `xmpdm_genre` varchar(128) collate utf8_unicode_ci default NULL,
  `xmp_baseurl` varchar(512) collate utf8_unicode_ci default NULL,
  `xmp_createdate` datetime default NULL,
  `xmp_rating` varchar(80) collate utf8_unicode_ci default NULL,
  `cansscontent_thumbnail` varchar(512) collate utf8_unicode_ci default NULL,
  `xmpdm_duration` bigint(20) default NULL,
  `xmpdm_copyrighttype` varchar(10) collate utf8_unicode_ci default NULL,
  `xmpdm_copyright` varchar(1024) collate utf8_unicode_ci default NULL,
  `xmpdm_videoframesize` varchar(20) collate utf8_unicode_ci default NULL,
  `xmpdm_moddate` datetime default NULL,
  `canssvideo_audiocodecs` varchar(40) collate utf8_unicode_ci default NULL,
  `canssvideo_videocodecs` varchar(40) collate utf8_unicode_ci default NULL,
  `canssvideo_filesize` bigint(20) default NULL,
  `cansstv_p_startdate` datetime default NULL,
  `cansstv_p_enddate` datetime default NULL,
  `cansstv_islive` tinyint(1) default NULL,
  `cansstv_isrerun` tinyint(1) default NULL,
  `canssContentDescription_owner` varchar(80) collate utf8_unicode_ci default NULL,
  PRIMARY KEY  (`tblCID_cid`),
  KEY `tblContent_FKIndex1` (`tblCID_cid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ");

	mysql_query(" DROP TABLE IF EXISTS `tblContentDescription`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `tblContentDescription` (
  `tblCID_cid` varchar(255) collate utf8_unicode_ci NOT NULL,
  `tblPID_pid` varchar(80) collate utf8_unicode_ci default NULL,
  `cansscontentdescription_status` int(10) unsigned NOT NULL,
  `cansscontentdescription_views` int(10) unsigned default NULL,
  `cansscontentdescription_rating` int(10) unsigned default NULL,
  `cansscontentdescription_pricevalue` double default NULL,
  `cansscontentdescription_priceatt_currencycode` varchar(20) collate utf8_unicode_ci default NULL,
  `cansscontentdescription_validatt_name` varchar(255) collate utf8_unicode_ci default NULL,
  `cansscontentdescription_validatt_start` datetime default NULL,
  `cansscontentdescription_validatt_end` datetime default NULL,
  PRIMARY KEY  (`tblCID_cid`),
  KEY `tblContentDecription_FKIndex1` (`tblCID_cid`),
  KEY `tblContentDecription_FKIndex2` (`tblPID_pid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ");

	mysql_query(" DROP TABLE IF EXISTS `tblContentStatusDescription`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `tblContentStatusDescription` (
  `eventid` int(10) unsigned NOT NULL,
  `statusdesc` varchar(50) collate utf8_unicode_ci NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ");

	mysql_query(" DROP TABLE IF EXISTS `tblContentsChannelHolds`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `tblContentsChannelHolds` (
  `tblChannel_tblPID_pid` varchar(80) collate utf8_unicode_ci NOT NULL,
  `tblChannel_index_2` int(10) unsigned NOT NULL,
  `filter_rule` text collate utf8_unicode_ci,
  PRIMARY KEY  (`tblChannel_tblPID_pid`,`tblChannel_index_2`),
  KEY `tblContentsChannelHolds_FKIndex1` (`tblChannel_index_2`,`tblChannel_tblPID_pid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ");

	mysql_query(" DROP TABLE IF EXISTS `tblContentsUsageCache`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `tblContentsUsageCache` (
  `tblPID_pid` varchar(80) collate utf8_unicode_ci NOT NULL,
  `index_2` int(10) unsigned NOT NULL auto_increment,
  `tblCID_cid` varchar(255) collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (`tblPID_pid`,`index_2`),
  KEY `tblContentsUsageCache_FKIndex1` (`tblPID_pid`),
  KEY `tblContentsUsageCache_FKIndex2` (`tblCID_cid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; ");

	mysql_query(" DROP TABLE IF EXISTS `tblCredit`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `tblCredit` (
  `index_2` int(10) unsigned NOT NULL auto_increment,
  `tblContent_tblCID_cid` varchar(255) collate utf8_unicode_ci NOT NULL,
  `canssvideo_creditrole` varchar(20) collate utf8_unicode_ci NOT NULL,
  `canssvideo_credit` varchar(255) collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (`index_2`),
  KEY `tblCredit_FKIndex1` (`tblContent_tblCID_cid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; ");

	mysql_query(" DROP TABLE IF EXISTS `tblEvent`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `tblEvent` (
  `tblMID_mid` varchar(80) collate utf8_unicode_ci NOT NULL,
  `tblEventDescription_eventid` int(10) unsigned NOT NULL,
  `canssevent_provideratt_seqnum` bigint(10) unsigned NOT NULL auto_increment,
  `canssevent_timecreatedatt_timestamp` datetime NOT NULL,
  `canssevent_extradata` text collate utf8_unicode_ci,
  PRIMARY KEY  (`tblMID_mid`,`tblEventDescription_eventid`,`canssevent_provideratt_seqnum`,`canssevent_timecreatedatt_timestamp`),
  KEY `tblEvent_FKIndex1` (`tblMID_mid`),
  KEY `tblEvent_FKIndex2` (`tblEventDescription_eventid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; ");

	mysql_query(" DROP TABLE IF EXISTS `tblEventDescription`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `tblEventDescription` (
  `eventid` int(10) unsigned NOT NULL,
  `level` int(10) unsigned NOT NULL,
  `eventname` varchar(200) collate utf8_unicode_ci NOT NULL,
  `oneLineDesc` varchar(255) collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (`eventid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ");

	mysql_query(" DROP TABLE IF EXISTS `tblFeed`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `tblFeed` (
  `index_2` int(10) unsigned NOT NULL auto_increment,
  `tblPID_pid` varchar(80) collate utf8_unicode_ci NOT NULL,
  `tblMID_mid` varchar(80) collate utf8_unicode_ci NOT NULL,
  `feeduri` varchar(255) collate utf8_unicode_ci NOT NULL,
  `ruleid` varchar(255) collate utf8_unicode_ci default NULL,
  `feedstatus` int(10) unsigned NOT NULL,
  PRIMARY KEY  (`index_2`,`tblPID_pid`,`tblMID_mid`),
  KEY `tblFeed_FKIndex1` (`tblPID_pid`),
  KEY `tblFeed_FKIndex2` (`tblMID_mid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; ");

	mysql_query(" DROP TABLE IF EXISTS `tblIPAllocData`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `tblIPAllocData` (
  `begin_ip` varchar(16) collate utf8_unicode_ci NOT NULL,
  `end_ip` varchar(16) collate utf8_unicode_ci NOT NULL,
  `begin_num` int(10) unsigned NOT NULL,
  `end_num` int(10) unsigned NOT NULL,
  `country` varchar(4) collate utf8_unicode_ci NOT NULL,
  `name` varchar(20) collate utf8_unicode_ci NOT NULL,
  KEY `begin_num` (`begin_num`),
  KEY `end_num` (`end_num`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ");

	mysql_query(" DROP TABLE IF EXISTS `tblLinkage`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `tblLinkage` (
  `tblPID_pid` varchar(80) collate utf8_unicode_ci NOT NULL,
  `tblCID_cid` varchar(255) collate utf8_unicode_ci NOT NULL,
  `ContId` text collate utf8_unicode_ci,
  KEY `tblLinkage_FKIndex1` (`tblCID_cid`),
  KEY `tblLinkage_FKIndex2` (`tblPID_pid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ");

	mysql_query(" DROP TABLE IF EXISTS `tblLocation`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `tblLocation` (
  `index_2` int(10) unsigned NOT NULL auto_increment,
  `tblContent_tblCID_cid` varchar(255) collate utf8_unicode_ci NOT NULL,
  `locationprotocol` varchar(10) collate utf8_unicode_ci NOT NULL,
  `location` varchar(512) collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (`index_2`,`tblContent_tblCID_cid`),
  KEY `tblLocation_FKIndex1` (`tblContent_tblCID_cid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; ");

	mysql_query(" DROP TABLE IF EXISTS `tblMID`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `tblMID` (
  `mid` varchar(80) collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (`mid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ");

	mysql_query(" DROP TABLE IF EXISTS `tblMarkers`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `tblMarkers` (
  `index_2` int(10) unsigned zerofill NOT NULL auto_increment,
  `tblContent_tblCID_cid` varchar(255) collate utf8_unicode_ci NOT NULL,
  `xmpdm_comment` varchar(256) collate utf8_unicode_ci default NULL,
  `xmpdm_name` varchar(128) collate utf8_unicode_ci default NULL,
  `xmpdm_starttime` bigint(20) NOT NULL,
  `xmpdm_location` varchar(512) collate utf8_unicode_ci default NULL,
  PRIMARY KEY  (`index_2`),
  KEY `tblMarkers_FKIndex1` (`tblContent_tblCID_cid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; ");

	mysql_query(" DROP TABLE IF EXISTS `tblModule`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `tblModule` (
  `tblMID_mid` varchar(80) collate utf8_unicode_ci NOT NULL,
  `cansstrace_modulecomputer` varchar(45) collate utf8_unicode_ci NOT NULL,
  `cansstrace_moduleversion` varchar(20) collate utf8_unicode_ci default NULL,
  `cansstrace_location` varchar(255) collate utf8_unicode_ci default NULL,
  `cansstrace_key` varchar(255) collate utf8_unicode_ci default NULL,
  PRIMARY KEY  (`tblMID_mid`),
  KEY `tblTrace_FKIndex1` (`tblMID_mid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ");

	mysql_query(" DROP TABLE IF EXISTS `tblModuleDescription`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `tblModuleDescription` (
  `tblMID_mid` varchar(80) collate utf8_unicode_ci NOT NULL,
  `tblPID_pid` varchar(80) collate utf8_unicode_ci default NULL,
  `name` varchar(80) collate utf8_unicode_ci default NULL,
  `commands` varchar(255) collate utf8_unicode_ci default NULL,
  `netaddr` varchar(255) collate utf8_unicode_ci default NULL,
  `midstatus` varchar(255) collate utf8_unicode_ci default NULL,
  `timestamp` bigint(20) unsigned default NULL,
  PRIMARY KEY  (`tblMID_mid`),
  KEY `Table_19_FKIndex1` (`tblMID_mid`),
  KEY `Table_19_FKIndex2` (`tblPID_pid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ");

	mysql_query(" DROP TABLE IF EXISTS `tblPID`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `tblPID` (
  `pid` varchar(80) collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (`pid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ");

	mysql_query(" DROP TABLE IF EXISTS `tblPerson`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `tblPerson` (
  `tblPID_pid` varchar(80) collate utf8_unicode_ci NOT NULL,
  `canssperson_pw` varchar(45) collate utf8_unicode_ci NOT NULL,
  `canssperson_name` varchar(20) collate utf8_unicode_ci default NULL,
  `canssperson_type` int(10) unsigned NOT NULL,
  `canssperson_typeatt_key` varchar(255) collate utf8_unicode_ci default NULL,
  `canssperson_language` varchar(20) collate utf8_unicode_ci default NULL,
  `local_session` varchar(255) collate utf8_unicode_ci default NULL,
  `local_entrydate` datetime NOT NULL,
  `canssperson_phone` varchar(20) collate utf8_unicode_ci default NULL,
  `canssperson_email` varchar(80) collate utf8_unicode_ci default NULL,
  PRIMARY KEY  (`tblPID_pid`),
  KEY `tblPerson_FKIndex1` (`tblPID_pid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ");

	mysql_query(" DROP TABLE IF EXISTS `tblPersonDescription`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `tblPersonDescription` (
  `tblPID_pid` varchar(80) collate utf8_unicode_ci NOT NULL,
  `pub_buztype` int(10) unsigned NOT NULL,
  `pub_name` varchar(80) collate utf8_unicode_ci default NULL,
  `pub_regnum` varchar(45) collate utf8_unicode_ci default NULL,
  `pub_category` varchar(45) collate utf8_unicode_ci default NULL,
  `pub_people` varchar(20) collate utf8_unicode_ci default NULL,
  `pub_money` varchar(45) collate utf8_unicode_ci default NULL,
  `pub_year` varchar(20) collate utf8_unicode_ci default NULL,
  `pub_ceo` varchar(80) collate utf8_unicode_ci default NULL,
  `pub_ceophone` varchar(20) collate utf8_unicode_ci default NULL,
  `pub_addr` varchar(255) collate utf8_unicode_ci default NULL,
  PRIMARY KEY  (`tblPID_pid`),
  KEY `tblPersonDescription_FKIndex1` (`tblPID_pid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ");

	mysql_query(" DROP TABLE IF EXISTS `tblTreatment`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `tblTreatment` (
  `index_2` int(10) unsigned NOT NULL auto_increment,
  `tblEvent_tblMID_mid` varchar(80) collate utf8_unicode_ci NOT NULL,
  `tblEvent_tblEventDescription_eventid` int(10) unsigned NOT NULL,
  `tblEvent_canssevent_provideratt_seqnum` int(10) unsigned NOT NULL,
  `tblEvent_canssevent_timecreatedatt_timestamp` datetime NOT NULL,
  `canssevent_treatdesc` varchar(255) collate utf8_unicode_ci NOT NULL,
  `att_date` datetime NOT NULL,
  PRIMARY KEY  (`index_2`,`tblEvent_tblMID_mid`,`tblEvent_tblEventDescription_eventid`,`tblEvent_canssevent_provideratt_seqnum`,`tblEvent_canssevent_timecreatedatt_timestamp`),
  KEY `tblTreatment_FKIndex1` (`tblEvent_tblMID_mid`,`tblEvent_tblEventDescription_eventid`,`tblEvent_canssevent_provideratt_seqnum`,`tblEvent_canssevent_timecreatedatt_timestamp`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; ");

	mysql_query(" DROP VIEW IF EXISTS `viewContentsInAgg`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `viewContentsInAgg` (
`tblCID_cid` varchar(255)
,`tblPID_pid` varchar(80)
,`cansscontentdescription_status` int(10) unsigned
,`cansscontentdescription_views` int(10) unsigned
,`cansscontentdescription_rating` int(10) unsigned
,`cansscontentdescription_pricevalue` double
,`cansscontentdescription_priceatt_currencycode` varchar(20)
,`cansscontentdescription_validatt_name` varchar(255)
,`cansscontentdescription_validatt_start` datetime
,`cansscontentdescription_validatt_end` datetime
); ");


	mysql_query(" DROP VIEW IF EXISTS `viewContentsInEnc`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `viewContentsInEnc` (
`tblCID_cid` varchar(255)
,`tblPID_pid` varchar(80)
,`cansscontentdescription_status` int(10) unsigned
,`cansscontentdescription_views` int(10) unsigned
,`cansscontentdescription_rating` int(10) unsigned
,`cansscontentdescription_pricevalue` double
,`cansscontentdescription_priceatt_currencycode` varchar(20)
,`cansscontentdescription_validatt_name` varchar(255)
,`cansscontentdescription_validatt_start` datetime
,`cansscontentdescription_validatt_end` datetime
); ");



	mysql_query(" DROP VIEW IF EXISTS `viewContentsInPor`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `viewContentsInPor` (
`tblCID_cid` varchar(255)
,`tblPID_pid` varchar(80)
,`cansscontentdescription_status` int(10) unsigned
,`cansscontentdescription_views` int(10) unsigned
,`cansscontentdescription_rating` int(10) unsigned
,`cansscontentdescription_pricevalue` double
,`cansscontentdescription_priceatt_currencycode` varchar(20)
,`cansscontentdescription_validatt_name` varchar(255)
,`cansscontentdescription_validatt_start` datetime
,`cansscontentdescription_validatt_end` datetime
); ");


	mysql_query(" DROP VIEW IF EXISTS `viewEventLog`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `viewEventLog` (
`canssModule_mid` varchar(80)
,`canssModule_name` varchar(80)
,`canssEvent_EventID` int(10) unsigned
,`canssEvent_EventName` varchar(200)
,`canssEvent_EventSeqnum` bigint(10) unsigned
,`canssEvent_Timestamp` datetime
); ");


	mysql_query(" DROP TABLE IF EXISTS `viewContentsInAgg`; ");

	mysql_query(" CREATE ALGORITHM=UNDEFINED DEFINER=`canss`@`localhost` SQL SECURITY DEFINER VIEW `viewContentsInAgg` AS select `tblContentDescription`.`tblCID_cid` AS `tblCID_cid`,`tblContentDescription`.`tblPID_pid` AS `tblPID_pid`,`tblContentDescription`.`cansscontentdescription_status` AS `cansscontentdescription_status`,`tblContentDescription`.`cansscontentdescription_views` AS `cansscontentdescription_views`,`tblContentDescription`.`cansscontentdescription_rating` AS `cansscontentdescription_rating`,`tblContentDescription`.`cansscontentdescription_pricevalue` AS `cansscontentdescription_pricevalue`,`tblContentDescription`.`cansscontentdescription_priceatt_currencycode` AS `cansscontentdescription_priceatt_currencycode`,`tblContentDescription`.`cansscontentdescription_validatt_name` AS `cansscontentdescription_validatt_name`,`tblContentDescription`.`cansscontentdescription_validatt_start` AS `cansscontentdescription_validatt_start`,`tblContentDescription`.`cansscontentdescription_validatt_end` AS `cansscontentdescription_validatt_end` from `tblContentDescription` where (floor((`tblContentDescription`.`cansscontentdescription_status` / 100)) = 1); ");

	mysql_query(" DROP TABLE IF EXISTS `viewContentsInEnc`; ");

	mysql_query(" CREATE ALGORITHM=UNDEFINED DEFINER=`canss`@`localhost` SQL SECURITY DEFINER VIEW `viewContentsInEnc` AS select `tblContentDescription`.`tblCID_cid` AS `tblCID_cid`,`tblContentDescription`.`tblPID_pid` AS `tblPID_pid`,`tblContentDescription`.`cansscontentdescription_status` AS `cansscontentdescription_status`,`tblContentDescription`.`cansscontentdescription_views` AS `cansscontentdescription_views`,`tblContentDescription`.`cansscontentdescription_rating` AS `cansscontentdescription_rating`,`tblContentDescription`.`cansscontentdescription_pricevalue` AS `cansscontentdescription_pricevalue`,`tblContentDescription`.`cansscontentdescription_priceatt_currencycode` AS `cansscontentdescription_priceatt_currencycode`,`tblContentDescription`.`cansscontentdescription_validatt_name` AS `cansscontentdescription_validatt_name`,`tblContentDescription`.`cansscontentdescription_validatt_start` AS `cansscontentdescription_validatt_start`,`tblContentDescription`.`cansscontentdescription_validatt_end` AS `cansscontentdescription_validatt_end` from `tblContentDescription` where (floor((`tblContentDescription`.`cansscontentdescription_status` / 100)) = 2); ");

	mysql_query(" DROP TABLE IF EXISTS `viewContentsInPor`; ");

	mysql_query(" CREATE ALGORITHM=UNDEFINED DEFINER=`canss`@`localhost` SQL SECURITY DEFINER VIEW `viewContentsInPor` AS select `tblContentDescription`.`tblCID_cid` AS `tblCID_cid`,`tblContentDescription`.`tblPID_pid` AS `tblPID_pid`,`tblContentDescription`.`cansscontentdescription_status` AS `cansscontentdescription_status`,`tblContentDescription`.`cansscontentdescription_views` AS `cansscontentdescription_views`,`tblContentDescription`.`cansscontentdescription_rating` AS `cansscontentdescription_rating`,`tblContentDescription`.`cansscontentdescription_pricevalue` AS `cansscontentdescription_pricevalue`,`tblContentDescription`.`cansscontentdescription_priceatt_currencycode` AS `cansscontentdescription_priceatt_currencycode`,`tblContentDescription`.`cansscontentdescription_validatt_name` AS `cansscontentdescription_validatt_name`,`tblContentDescription`.`cansscontentdescription_validatt_start` AS `cansscontentdescription_validatt_start`,`tblContentDescription`.`cansscontentdescription_validatt_end` AS `cansscontentdescription_validatt_end` from `tblContentDescription` where (floor((`tblContentDescription`.`cansscontentdescription_status` / 100)) = 3); ");

	mysql_query(" DROP TABLE IF EXISTS `viewEventLog`; ");

	mysql_query(" CREATE ALGORITHM=UNDEFINED DEFINER=`canss`@`localhost` SQL SECURITY DEFINER VIEW `viewEventLog` AS select `tblEvent`.`tblMID_mid` AS `canssModule_mid`,`tblModuleDescription`.`name` AS `canssModule_name`,`tblEvent`.`tblEventDescription_eventid` AS `canssEvent_EventID`,`tblEventDescription`.`eventname` AS `canssEvent_EventName`,`tblEvent`.`canssevent_provideratt_seqnum` AS `canssEvent_EventSeqnum`,`tblEvent`.`canssevent_timecreatedatt_timestamp` AS `canssEvent_Timestamp` from ((`tblModuleDescription` join `tblEvent`) join `tblEventDescription`) where ((`tblModuleDescription`.`tblMID_mid` = `tblEvent`.`tblMID_mid`) and (`tblEvent`.`tblEventDescription_eventid` = `tblEventDescription`.`eventid`)) order by `tblEvent`.`canssevent_timecreatedatt_timestamp` desc; ");

	mysql_query(" DROP DATABASE IF EXISTS `rule_db`; ");
	mysql_query(" CREATE DATABASE `rule_db` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; ");
	mysql_query(" USE `rule_db`; ");

	mysql_query(" DROP TABLE IF EXISTS `rule`; ");
	mysql_query(" CREATE TABLE IF NOT EXISTS `rule` (
  `rid` varchar(40) collate utf8_unicode_ci NOT NULL,
  `namespaces` text collate utf8_unicode_ci NOT NULL,
  `map` text collate utf8_unicode_ci NOT NULL,
  `XSL` text collate utf8_unicode_ci NOT NULL,
  `rname` varchar(256) collate utf8_unicode_ci NOT NULL,
  `rdesc` text collate utf8_unicode_ci NOT NULL,
  `encType` tinyint(4) NOT NULL,
  PRIMARY KEY  (`rid`),
  FULLTEXT KEY `map` (`map`,`XSL`,`rdesc`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ");



	echo "db creation	: comp<br/>";
	}

	if( $_GET[contents] ){
		mysql_select_db( 'contentsmetadata_db' );
		mysql_query( "TRUNCATE TABLE `tblCID`;");
		mysql_query( "TRUNCATE TABLE `tblContentDescription`;");
		mysql_query( "TRUNCATE TABLE `tblContent`;");
		mysql_query( "TRUNCATE TABLE `tblLocation`;");
		mysql_query( "TRUNCATE TABLE `tblContentsUsageCache`;");
		mysql_query( "TRUNCATE TABLE `tblLinkage`;");
		mysql_query( "UPDATE `tblContentsChannelHolds` SET `filter_rule`=NULL;");
		echo "contents	: comp<br/>";
	}
	if( $_GET[eventdesc] )
	{
		mysql_select_db( 'contentsmetadata_db' );
		mysql_query( "SET NAMES 'utf8'" );
		mysql_query( "TRUNCATE TABLE `tblEventDescription`;" );
		mysql_query( "INSERT IGNORE INTO `tblEventDescription` (`eventid`, `level`, `eventname`, `oneLineDesc`) VALUES
(246, 0, 'STATUS_CONTENTS_ENC_52', '인코딩 진행중, 52%'),
(250, 0, 'STATUS_CONTENTS_ENC_60', '인코딩 진행중, 60%'),
(251, 0, 'STATUS_CONTENTS_ENC_62', '인코딩 진행중, 62%'),
(252, 0, 'STATUS_CONTENTS_ENC_64', '인코딩 진행중, 64%'),
(253, 0, 'STATUS_CONTENTS_ENC_66', '인코딩 진행중, 66%'),
(254, 0, 'STATUS_CONTENTS_ENC_68', '인코딩 진행중, 68%'),
(255, 0, 'STATUS_CONTENTS_ENC_70', '인코딩 진행중, 70%'),
(256, 0, 'STATUS_CONTENTS_ENC_72', '인코딩 진행중, 72%'),
(258, 0, 'STATUS_CONTENTS_ENC_76', '인코딩 진행중, 76%'),
(257, 0, 'STATUS_CONTENTS_ENC_74', '인코딩 진행중, 74%'),
(259, 0, 'STATUS_CONTENTS_ENC_78', '인코딩 진행중, 78%'),
(260, 0, 'STATUS_CONTENTS_ENC_80', '인코딩 진행중, 80%'),
(261, 0, 'STATUS_CONTENTS_ENC_82', '인코딩 진행중, 82%'),
(262, 0, 'STATUS_CONTENTS_ENC_84', '인코딩 진행중, 84%'),
(263, 0, 'STATUS_CONTENTS_ENC_86', '인코딩 진행중, 86%'),
(264, 0, 'STATUS_CONTENTS_ENC_88', '인코딩 진행중, 88%'),
(265, 0, 'STATUS_CONTENTS_ENC_90', '인코딩 진행중, 90%'),
(266, 0, 'STATUS_CONTENTS_ENC_92', '인코딩 진행중, 92%'),
(267, 0, 'STATUS_CONTENTS_ENC_94', '인코딩 진행중, 94%'),
(320, 0, 'STATUS_CONTENT_BLOCKED', '제한된 컨텐트'),
(299, 0, 'STATUS_CONTENTS_ENC_FAIL', '인코딩에 실패하였습니다.'),
(277, 0, 'STATUS_CONTENTS_ENCODED', '인코딩이 완료되었습니다.'),
(219, 0, 'STATUS_CONTENTS_CNF', 'STATUS_CONTENTS_CNF'),
(210, 0, 'STATUS_CONTENTS_ENCODING', '컨텐트를 인코딩하고 있습니다.'),
(200, 0, 'STATUS_CONTENTS_MMINIT', '인코딩을 기다리고 있습니다.'),
(177, 0, 'STATUS_CONTENTS_UPLOADED', '컨텐트가 서버에 업로드되었습니다.'),
(0, 0, 'STATUS_CONTENTS_INITIAL', '컨텐츠 정보를 발견하였습니다.'),
(270, 0, 'STATUS_CONTENTS_ENC_100', '인코딩 진행중, 100%'),
(269, 0, 'STATUS_CONTENTS_ENC_98', '인코딩 진행중, 98%'),
(268, 0, 'STATUS_CONTENTS_ENC_96', '인코딩 진행중, 96%'),
(220, 0, 'STATUS_CONTENTS_ENC_0', '인코딩 진행중, 0%'),
(221, 0, 'STATUS_CONTENTS_ENC_2', '인코딩 진행중, 2%'),
(222, 0, 'STATUS_CONTENTS_ENC_4', '인코딩 진행중, 4%'),
(223, 0, 'STATUS_CONTENTS_ENC_6', '인코딩 진행중, 6%'),
(224, 0, 'STATUS_CONTENTS_ENC_8', '인코딩 진행중, 8%'),
(225, 0, 'STATUS_CONTENTS_ENC_10', '인코딩 진행중, 10%'),
(226, 0, 'STATUS_CONTENTS_ENC_12', '인코딩 진행중, 12%'),
(227, 0, 'STATUS_CONTENTS_ENC_14', '인코딩 진행중, 14%'),
(228, 0, 'STATUS_CONTENTS_ENC_16', '인코딩 진행중, 16%'),
(229, 0, 'STATUS_CONTENTS_ENC_18', '인코딩 진행중, 18%'),
(230, 0, 'STATUS_CONTENTS_ENC_20', '인코딩 진행중, 20%'),
(231, 0, 'STATUS_CONTENTS_ENC_22', '인코딩 진행중, 22%'),
(232, 0, 'STATUS_CONTENTS_ENC_24', '인코딩 진행중, 24%'),
(233, 0, 'STATUS_CONTENTS_ENC_26', '인코딩 진행중, 26%'),
(234, 0, 'STATUS_CONTENTS_ENC_28', '인코딩 진행중, 28%'),
(235, 0, 'STATUS_CONTENTS_ENC_30', '인코딩 진행중, 30%'),
(236, 0, 'STATUS_CONTENTS_ENC_32', '인코딩 진행중, 32%'),
(237, 0, 'STATUS_CONTENTS_ENC_34', '인코딩 진행중, 34%'),
(238, 0, 'STATUS_CONTENTS_ENC_36', '인코딩 진행중, 36%'),
(239, 0, 'STATUS_CONTENTS_ENC_38', '인코딩 진행중, 38%'),
(240, 0, 'STATUS_CONTENTS_ENC_40', '인코딩 진행중, 40%'),
(241, 0, 'STATUS_CONTENTS_ENC_42', '인코딩 진행중, 42%'),
(242, 0, 'STATUS_CONTENTS_ENC_44', '인코딩 진행중, 44%'),
(243, 0, 'STATUS_CONTENTS_ENC_46', '인코딩 진행중, 46%'),
(244, 0, 'STATUS_CONTENTS_ENC_48', '인코딩 진행중, 48%'),
(245, 0, 'STATUS_CONTENTS_ENC_50', '인코딩 진행중, 50%'),
(249, 0, 'STATUS_CONTENTS_ENC_58', '인코딩 진행중, 58%'),
(248, 0, 'STATUS_CONTENTS_ENC_56', '인코딩 진행중, 56%'),
(247, 0, 'STATUS_CONTENTS_ENC_54', '인코딩 진행중, 54%'),
(300, 0, 'STATUS_CONTENT_READY_PRI', '컨텐트 완료. (비공개)'),
(310, 0, 'STATUS_CONTENT_READY_PUB', '컨텐트 완료. (공개)'),
(330, 0, 'STATUS_CONTENT_DELETED', '삭제된 컨텐트'),
(120, 0, 'STATUS_CONTENTS_DOWNLOADED', '풀링이 완료되었습니다.'),
(130, 0, 'STATUS_CONTENTS_UPLOAD_READY', '서버에 업로드를 대기중입니다.'),
(100, 0, 'STATUS_CONTENTS_DOWNLOAD_READY', '컨텐트 폴링을 준비중입니다.'),
(110, 0, 'STATUS_CONTENTS_DOWNLOADING', '컨텐트를 폴링하는 중입니다.'),
(340, 0, 'STATUS_CONTENTS_REUPLOADABLE', '재 업로드를 기다리고 있습니다.'),
(381, 0, 'PORTAL_LOG_INFO', '정보'),
(382, 1, 'PORTAL_LOG_NOTICE', '통지'),
(383, 2, 'PORTAL_LOG_WARNING', '경고'),
(384, 5, 'PORTAL_LOG_ERROR', '오류'),
(288, 0, 'MM_TESTMESSAGE', 'Test message'),
(401, 0, 'MEDIAFARM_INFO', 'MediaFarm 정보'),
(391, 0, 'LOG_PORTAL_USERJOIN', '유저 가입'),
(392, 0, 'LOG_PORTAL_USERLOGIN', '유저 로그인'),
(393, 0, 'LOG_PORTAL_WEBPAGE_REQUEST', '웹 페이지 요청'),
(394, 0, 'LOG_PORTAL_CONTENTSEARCH_REQUEST', '컨텐츠 검색'),
(395, 0, 'LOG_PORTAL_CONTENTDETAIL_REQUEST', '컨텐츠 열람');
 " );
		echo "event desc	: comp<br/>";
	}
	if( $_GET[moduledesc] )
	{
		mysql_select_db( 'contentsmetadata_db' );
		mysql_query("SET NAMES 'utf8'");
		mysql_query("TRUNCATE TABLE `tblMID`; ");
		mysql_query("TRUNCATE TABLE `tblModuleDescription`; ");
		mysql_query("INSERT IGNORE INTO `tblMID` (`mid`) VALUES
('100'),
('110'),
('120'),
('130'); ");
		mysql_query("INSERT IGNORE INTO `tblModuleDescription` (`tblMID_mid`, `tblPID_pid`, `name`, `commands`, `netaddr`, `midstatus`, `timestamp`) VALUES
('100', '', 'Aggregator1', 'turnon, turnoff', '', 'on', 1286344069852),
('110', '', 'Mediator', '', '', 'running', 1286344071435),
('120', 'admin', 'Portal', '', '', 'running', 1286344071783),
('130', 'admin', 'MediaFarm', '', '', 'running', 1286344072138); ");
		echo "module desc	: comp<br/>";
	}
	if( $_GET[tempmedia] )
	{
		exec("rm /var/www/MediaSource/khj/* -f");
		exec("pkill JobScheduler");
		exec("pkill ffmpeg");
		exec("pkill vsftpd");
		echo "tempmedia	: comp<br/>";
	}

	if( $_GET[person] )
	{
		mysql_select_db( 'contentsmetadata_db' );
		mysql_query( "TRUNCATE TABLE `tblPID`;");
		mysql_query( "TRUNCATE TABLE `tblPerson`;");
		mysql_query( "INSERT INTO `tblPID` (`pid`) VALUES ('admin');");
		mysql_query( "INSERT INTO `tblPerson` (`tblPID_pid`, `canssperson_pw`, `canssperson_name`, `canssperson_type`, `canssperson_typeatt_key`, `canssperson_language`, `local_session`, `local_entrydate`) VALUES ('admin', '21232F297A57A5A743894A0E4A801FC3', 'admin', 10, NULL, NULL, NULL, NOW());");
		mysql_query( "TRUNCATE TABLE `tblChannel`;");
		mysql_query( "TRUNCATE TABLE `tblContentsChannelHolds`;");
		mysql_query( "TRUNCATE TABLE `tblFeed`;");
		mysql_query( "TRUNCATE TABLE `tblPersonDescription`;");
		echo "person		: comp<br/>";
	}

	if( $_GET[mediafarm] && $_GET[contents] ){
		exec("rm /var/www/MediaFarm/Content/* -f");
		echo "mediafarm	: comp<br/>";
	}else if( $_GET[mediafarm] )
	{
		echo "mediafarm : not comp (use both)<br/>";
	}

	if( $_GET[tempmeta] ){
		exec("rm /tmp/wsdl-*");
		exec("rm /var/www/MetadataManager/tmp/*");
		echo "tempmeta	: comp<br/>";
	}

	if( $_GET[encoder_log] ){
		exec("rm /var/www/log/*");
		exec("touch /var/www/log/Encoder.log");
		echo "encoder_log	: comp<br/>";
	}
	

?>
<hr width=40% align=left />
| menu | <a href="http://canss.net">go Home</a> |
<hr width=40% align=left />
<form method=get action=clear.php >
 <input type=checkbox name=dbs value=1 />db creation	: create dbs and tables
 <br/>
 <input type=checkbox name=contents value=1 />contents 	: remove Contents
 <input type=checkbox name=tempmedia value=1 />tempmedia	: remove temporary folder for encoder
 <input type=checkbox name=mediafarm value=1 />mediafarm	: remove mediafarm (use with opt.contents)
 <input type=checkbox name=tempmeta value=1 />tempmeta	: remove other temporary file
 <input type=checkbox name=person value=1 />person   	: remove Persons (than restore admin)
 <input type=checkbox name=encoder_log value=1 />encoder_log	: remove Encoder log
 <input type=checkbox name=eventdesc value=1 />event desc	: remove and reset event desc
 <input type=checkbox name=moduledesc value=1 />module desc	: remove and reset module desc

<hr width=40% align=left /> 
<input type=submit value=submit />
</form>
</pre>
